package com.meritdata.cloud.data.datasource.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.meritdata.cloud.data.base.Page;
import com.meritdata.cloud.data.datasource.model.Datasource;
import com.meritdata.cloud.data.datasource.service.IDatasourceService;

@RequestMapping("/datasource")
@Controller
public class DatasourceController {
	
	@Autowired
	private IDatasourceService service;
	
	@RequestMapping("/add")
	@ResponseBody
	public Datasource add(@RequestParam String name, @RequestParam String type){
		Datasource ds = new Datasource();
		ds.setName(name);
		ds.setType(type);
		service.add(ds);
		return ds;
	}
	
	@RequestMapping("/page")
	@ResponseBody
	public Page<Datasource> page(){
		Page page = new Page();
		page.setPageNum(1);
		page.setPageSize(4);
		return service.page(page);
	}

}
